package tp.pr5.items;

import tp.pr5.NavigationModule;
import tp.pr5.RobotEngine;

/**
 * The garbage is a type of item that generates recycled material after using it. 
 * The garbage can be used only once. After using it, it must be removed from the robot inventory
 *
 */

public class Garbage extends Item
{
	
	private final int recycledMaterial;
	boolean hasBeenUsed = false;
	
	/**
	 * @return id - Item id
     * @return description - Item description
     * @return recycledMaterial - The amount of recycled material that the item generates
	 */
	
	public Garbage(String id, String description, int recycledMaterial)
	{
		super(id, description);
		this.recycledMaterial = recycledMaterial;
	}
	
	/**
	 * Garbage can be used only once
	 * 
	 * @return true if the item has not been used yet
	 */

	public boolean canBeUsed()
	{
		return !hasBeenUsed;
	}

	/**
	 * The garbage generates recycled material for the robot that uses it
	 * 
	 * @return r - the robot that uses the item
	 * @return p - The place where the item is used
	 * @return true if the garbage was transformed in recycled material
	 * 
	 */
	
	public boolean use(RobotEngine r, NavigationModule nav)
	{
		if(canBeUsed())
		{
			hasBeenUsed = true;
			r.addRecycledMaterial(recycledMaterial);
			return true;	
		}
		else
		{ 
			return false;
		}
	}
	
	/**
	 * Generates a String with the Item description
	 * 
	 * @return string full description of item garbage
	 *
	 */
	public String toString()
	{
		return super.toString() + " // weight = " + recycledMaterial;
	}

	@Override
	public boolean canBeDefused() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int explode() {
		// TODO Auto-generated method stub
		return 0;
	}
	
}
